package com.example.demo.config;

import com.example.demo.interceptor.DashboardVerificationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private DashboardVerificationInterceptor dashboardVerificationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册dashboard验证拦截器，拦截所有/dashboard/**路径
        registry.addInterceptor(dashboardVerificationInterceptor)
                .addPathPatterns("/dashboard/**")
                // 不拦截验证页面和其他静态资源
                .excludePathPatterns("/verify-dashboard", "/css/**", "/js/**", "/images/**");
    }
} 